<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>小红书直达搜索</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        body {
            background: #fff;
            min-height: 100vh;
            margin: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-family: 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
        }
        .logo {
            margin-bottom: 28px;
        }
        .logo img.header-logo {
            width: 120px;
            height: auto;
            display: block;
        }
        .search-container {
            display: flex;
            align-items: center;
            background: #fafafa;
            border-radius: 22px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.03);
            padding: 0 14px;
            width: 320px;
            height: 44px;
        }
        .search-input {
            border: none;
            background: transparent;
            outline: none;
            font-size: 16px;
            flex: 1;
            color: #333;
        }
        .icon-btn {
            background: none;
            border: none;
            cursor: pointer;
            padding: 0 6px;
            display: flex;
            align-items: center;
        }
        .icon-btn svg {
            width: 20px;
            height: 20px;
            color: #bbb;
        }
        .icon-btn:active svg {
            color: #ff2d4a;
        }
    </style>
</head>
<body>
    <div class="logo">
        <!-- 小红书logo图片 -->
        <img crossorigin="anonymous" class="header-logo" style="pointer-events:none;" src="" data-v-5c1b2170="">
    </div>
    <div class="search-container">
        <input type="text" id="keyword" class="search-input" placeholder="输入搜索词" onkeydown="if(event.key==='Enter'){search()}"/>
        <button class="icon-btn" id="clearBtn" title="清除" onclick="clearInput()" style="display:none">
            <!-- X图标 -->
            <svg viewBox="0 0 24 24"><path d="M18 6L6 18M6 6l12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>
        </button>
        <button class="icon-btn" title="搜索" onclick="search()">
            <!-- 放大镜图标 -->
            <svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="7" stroke="currentColor" stroke-width="2" fill="none"/><line x1="16.5" y1="16.5" x2="21" y2="21" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>
        </button>
    </div>
    <script>
    /**
     * 执行小红书搜索
     * @returns {void}
     */
    function search() {
        const keyword = document.getElementById("keyword").value.trim();
        if (keyword) {
            const url = `https://www.xiaohongshu.com/search_result?keyword=${encodeURIComponent(keyword)}`;
            window.open(url);
        }
    }
    /**
     * 清空输入框内容
     * @returns {void}
     */
    function clearInput() {
        const input = document.getElementById("keyword");
        input.value = '';
        input.focus();
        document.getElementById('clearBtn').style.display = 'none';
    }
    // 输入框监听，控制清除按钮显示
    document.getElementById('keyword').addEventListener('input', function() {
        document.getElementById('clearBtn').style.display = this.value ? 'inline-flex' : 'none';
    });
    </script>
</body>
</html> 